package com.human.server.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.human.server.entity.Attendance;
import com.human.server.entity.Salary;
import com.human.server.model.request.AttendanceExcel;
import com.human.server.model.request.SalaryExcel;
import com.human.server.service.SalaryService;
import com.human.server.mapper.SalaryMapper;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
* @author Admin
* @description 针对表【salary(工资表)】的数据库操作Service实现
* @createDate 2025-09-14 12:02:11
*/
@Service
public class SalaryServiceImpl extends ServiceImpl<SalaryMapper, Salary>
    implements SalaryService{

    public void upload(MultipartFile file) throws IOException {

        EasyExcel.read(file.getInputStream(), SalaryExcel.class, new ReadListener<SalaryExcel>(){

            @Override
            public void invoke(SalaryExcel salaryExcel, AnalysisContext analysisContext) {
                Salary salary = new Salary();
                BeanUtil.copyProperties(salaryExcel, salary);
                baseMapper.insert(salary);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext analysisContext) {

            }
        }).sheet().doRead();
    }
}




